package com.ztc.controller;
import com.ztc.mapper.UserMapper;
import com.ztc.mapper.UserServiceImpl;
import com.ztc.service.BookDao;
import com.ztc.mapper.UserMapper;
import com.ztc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/user")
public class ZcController extends HttpServlet {
    @Autowired
    UserService userService;
    BookDao bookDao = new BookDao();
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        doPost(request,response);

    }
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String username = request.getParameter("username");
        boolean  b = userService.getusername2(username);
        System.out.println(b);
        if(b){
            response.getWriter().write("1");
        }else{
            response.getWriter().write("0");
        }

    }
}
